﻿@using BrnMall.Web.StoreAdmin.Models
@model BrnMall.Web.StoreAdmin.Models.WidgetConfigListModel
@{
    BrnMall.Manager.Domain.Messages.MessagesModel msgmodel = (BrnMall.Manager.Domain.Messages.MessagesModel)ViewData["model"];
}
@section header{
    <title>创意审核-留言管理</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css" />
    <script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.unobtrusive.js"></script>
    <link type="text/css" rel="stylesheet" href="/components/webuploader/webuploader.css" />
    <script type="text/javascript" src="/components/webuploader/webuploader.js"></script>
    <link href="/components/jbox/Skins/Default/jbox.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/components/jbox/jquery.jBox-2.3.min.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/showlist.js"></script>
    <script type="text/javascript" src="/components/my97datepicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/selectlist.js"></script>
    <style>
        .selectBt,.selectBox {top: 3px;left: 120px;position: absolute;}
    </style>

}
@section body{
    <h1 class="rightH1">
        微信小程序 &gt; 留言管理 &gt; <span class="rightH1-cur">创意审核</span>
        <div class="clear"></div>
    </h1>
    <div class="table_top">
    </div>

    <div class="table_bottom">
    </div>

    @using (Html.BeginForm("AddMegComment", "message"))
    {
        <input type="hidden" name="Msgid" value="@msgmodel.Msgid" />
        <input type="hidden" name="Comment" id="commenthid"/>
        <input type="hidden" id="type" />
        @Html.HiddenFor(x => x.Code)
        <div align="left" id="left" style="width:500px;height:400px;text-align:center; margin-bottom:10px; position:relative;">
            <div align="left" style="background-color:lightblue;margin-left:10px;margin-top:10px;">
                <h4 style="line-height:30px; text-align:center;"><span style="margin-left:10px;">@msgmodel.MsgTitle</span></h4>
            </div>
            <div align="left" style="margin-top:10px;">
                <span style="margin-left:10px;">@msgmodel.MsgContent</span>
            </div>

            <div align="left" style="margin-top:50px;margin-left:10px;">
                <span style="margin-left:10px; font-size:16px; font-weight:bold;">商家回复</span><br />
                @if (msgmodel.Comment == null || msgmodel.Comment == "")
                {
                    <textarea id="comment" style="width:480px;height:80px;"></textarea>
                }
                else
                {
                    <textarea id="comment" style="width:480px;height:80px;">@msgmodel.Comment</textarea>
                    <span style="margin-left:10px;"></span>
                }
            </div>
            <div style="margin-top:30px; margin-left:10px; position:relative">
                链接：
                <select id="linktype" class="linktype" name="linktype">
                    <option value="">选择分类</option>
                    <option value="product">商品</option>
                    <option value="store_class">店铺商品分类</option>
                    <option value="news">内容</option>
                    <option value="news_type">内容分类</option>
                    <option value="page">页面</option>
                    <option value="h5page">H5网页</option>
                    <option value="phonecall">一键拨号</option>
                </select><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;

                <div class="selectBt selectBox" id="selectProduct" style="display: none;margin-left:40px;">
                    <input type="button" value="选择商品" onclick="openProductSelectLayer(this)" style="height: 22px; line-height: 22px;  background: url(/admin_store/images/selectbgico.gif) no-repeat 6px center; padding-left: 22px; padding-right: 10px;">
                    <input type="hidden" class="Pid" id="Pid" name="Pid" value="" />
                    <input type="hidden" class="ProductName" id="ProductName" name="ProductName;margin-left:40px;" value="" />
                </div>
                <div class="selectBt selectBox" id="selectStoreClass" style="display: none;margin-left:40px;height:15px;">
                    @Html.DropDownList("StoreClassId", Model.StoreClassList.Select(t => new SelectListItem() { Selected = false, Text = t.Name, Value = t.StoreCid.ToString() }), "选择店铺分类")
                </div>

                <div class="selectBt selectBox" id="selectNewsType" style="display: none;margin-left:40px;height:15px;">
                    @Html.DropDownList("NewsTypeId", Model.NewsTypeList.Select(t => new SelectListItem() { Selected = false, Text = t.Name, Value = t.NewsTypeId.ToString() }), "选择内容分类")
                </div>
                <div class="selectBt selectBox" id="selectNews" style="display: none;margin-left:40px;">
                    <input type="button" value="选择内容" onclick="openNewsSelectLayer(this)" style="height: 22px; line-height: 22px; background: url(/admin_store/images/selectbgico.gif) no-repeat 6px center; padding-left: 22px; padding-right: 10px;" />
                    <input type="hidden" class="NewsId" id="NewsId" name="NewsId" value="" />
                    <input type="hidden" class="NewsName" id="NewsName" name="NewsName" value="" />
                </div>
                <div class="selectBt selectBox" id="selectPageInfo" style="display: none;margin-left:40px;">
                    @Html.DropDownList("PageInfoId", Model.PageInfos.Select(t => new SelectListItem() { Selected = false, Text = t.Name, Value = t.Id.ToString() }), "选择页面")
                </div>
                <div class="selectBox" id="selectH5Page" style="display: none;margin-left:40px;">
                    <input type="text" size="20" id="H5Page" name="H5Page" /><span>必须是https开头的网址</span>
                </div>
                <div class="selectBox" id="selectPhoneCall" style="display: none;margin-left:40px;">
                    <input type="text" size="20" id="PhoneNumber" name="PhoneNumber" /> 输入电话或手机号
                </div>
            </div>
            <div style="margin-left:10px;margin-top:-33px;">说明：审核后的留言，才能在小程序里显示</div>
            
            <div class="table_bottom" style="clear:both; position:relative; text-align:right;">
                
                <div class="button" id="back">返回列表</div>
                @if (msgmodel.IsCheck == 1)
                {
                    <div class="editOperate button">已审核</div>
                }
                else
                {
                    <div id="okcheck" class="button">审 核</div>
                } 
                <div class="button" id="noCheck">拒 绝</div>
            </div>
            <input type="submit" id="btn-submit" style="display:none" />
            <script type="text/javascript">
                $(function(){
                    $("#linktype").change(function () {
                        var sel = $(this).val();
                        $(".selectBox").css("display", "none");
                        if (sel === "product") {
                            $("#selectProduct").css("display", "block");
                        } else if (sel === "store_class") {
                            $("#selectStoreClass").css("display", "block");
                        } else if (sel === "news") {
                            $("#selectNews").css("display", "block");
                        } else if (sel === "news_type") {
                            $("#selectNewsType").css("display", "block");
                        } else if (sel === "page") {
                            $("#selectPageInfo").css("display", "block");
                        } else if (sel === "h5page") {
                            $("#selectH5Page").css("display", "block");
                        }
                        else if (sel === "phonecall") {
                            $("#selectPhoneCall").css("display", "block");
                        }
                    });           

                    //同意审核
                    $('#back').click(function () {
                        window.location.href="@Url.Action("MessageRow")";
                    });
                    //同意审核
                    $('#okcheck').click(function () {
                        submits('ok');
                    });
                
                    //拒接审核
                    $('#noCheck').click(function () {
                        $.jBox.confirm("您确定拒接审核吗？拒接之后将返回列表页。", "提示", function (v, h, f) {
                            if (v == "ok") {
                                submits('cacel');
                            }
                        });
                    });
                })

                function submits(checkType){
                    //店铺分类
                    var StoreClassName1=document.getElementById("StoreClassId").options[document.getElementById("StoreClassId").selectedIndex].text;
                    //新闻类型
                    var NewsTypeName1=document.getElementById("NewsTypeId").options[document.getElementById("NewsTypeId").selectedIndex].text;
                    //页面
                    var PageName1=document.getElementById("PageInfoId").options[document.getElementById("PageInfoId").selectedIndex].text;
                    //H5Page
                    var H5PageName1=null
                    //一般拨号
                    var PhoneNumberName1=null;
                    //表单参数
                    var param={
                        Msgid:@msgmodel.Msgid,LinkType:$('.linktype').val(),
                        Pid:$("#Pid").val(),ProductName:$("#ProductName").val(),
                        StoreClassId:$('#StoreClassId').val(),StoreClassName:StoreClassName1,
                        NewsId:$('#NewsId').val(),NewsName:$('NewsName').val(),
                        NewsTypeId:$('#NewsTypeId').val(),NewsTypeName:NewsTypeName1,
                        PageInfoId:$("#PageInfoId").val(),PageName:PageName1,
                        H5PageId:"",H5PageName:"",
                        PhoneNumberId:"",PhoneNumberName:"",
                        Comment:$("#comment").val(),
                        Ischeck  : (checkType =="ok" ? "1" : "2")   // "ok" 审核通过, "cacel" 拒绝
                    };

                    if(checkType=="ok"){
                        $.jBox.confirm("您确定同意审核吗？", "提示", function (v, h, f) {
                            if (v == "ok") {
                                $.post('@Url.Action("Edit")', param, function (data) {                                  
                                    if (data.indexOf("<h3>ok</h3>")>-1) {
                                        $.jBox.tip('审核成功！', 'success');
                                        setTimeout(function(){ window.location.reload()},1000);
                                    }
                                    else {
                                        $.jBox.tip('操作失败，请稍后再试！', 'success');
                                    }
                                });
                            }
                        });
                    }

                    if(checkType=="cacel"){
                        $.post('@Url.Action("Edit")', param, function (data) {
                            if (data.indexOf("<h3>ok</h3>")>-1) {
                                $.jBox.tip('操作成功！', 'success');
                                setTimeout(function(){ window.location.reload()},1000);
                            }else {
                                $.jBox.tip('操作失败，请稍后再试！', 'success');
                            }
                        });
                    }

                }
            </script>
        </div>
    }
}